-
-
Notifications
You must be signed in to change notification settings - Fork 46.6k
Made improvements to combinations.py #3681
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Made improvements to combinations.py #3681
Conversation
In relation to #3682 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct!
maths/combinations.py
Outdated
# If either of the conditions are true, the function is being asked | ||
# to calculate a factorial of a negative number, which is not possible | ||
if n < k or k < 0: | ||
print("Invalid value for n and/or k given.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should throw an exception instead of return -1
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm kind of new to doctests in general, how do I make the doctest for an exception?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nvm think I got it
Co-authored-by: Du Yuanchao <[email protected]>
@Rolv-Apneseth Thanks for your contribution :) |
No problem! |
* Made improvements to combinations.py * Update maths/combinations.py Co-authored-by: Du Yuanchao <[email protected]> * Function now raises an error when given invalid input * Update maths/combinations.py Co-authored-by: Du Yuanchao <[email protected]>
* Made improvements to combinations.py * Update maths/combinations.py Co-authored-by: Du Yuanchao <[email protected]> * Function now raises an error when given invalid input * Update maths/combinations.py Co-authored-by: Du Yuanchao <[email protected]>
* Made improvements to combinations.py * Update maths/combinations.py Co-authored-by: Du Yuanchao <[email protected]> * Function now raises an error when given invalid input * Update maths/combinations.py Co-authored-by: Du Yuanchao <[email protected]>
* Made improvements to combinations.py * Update maths/combinations.py Co-authored-by: Du Yuanchao <[email protected]> * Function now raises an error when given invalid input * Update maths/combinations.py Co-authored-by: Du Yuanchao <[email protected]>
I have made some improvements to combinations.py.
Added:
If you would like anything else, or if you don't like the changes, please let me know. Thanks!